package com.li.serve;
import com.li.mapper.UserMapper;
import org.apache.ibatis.io.Resources;
import org.apache.ibatis.session.SqlSession;
import org.apache.ibatis.session.SqlSessionFactory;
import org.apache.ibatis.session.SqlSessionFactoryBuilder;
import java.io.IOException;
import java.io.InputStream;

public class LiMbatis {
    public static void main(String[] args) {
        String resource = "mybatis-config.xml";
        InputStream inputStream;
        {
            try {
                inputStream = Resources.getResourceAsStream(resource);
                SqlSessionFactory sqlSessionFactory = new SqlSessionFactoryBuilder().build(inputStream);
                SqlSession sqlSession = sqlSessionFactory.openSession();
                UserMapper mapper = sqlSession.getMapper(UserMapper.class);
               // mapper.insert();
//                System.err.println(mapper.selectUser());
//                    mapper.deleteUSer();
//                mapper.updateUSer();
//                System.err.println(mapper.lisUser());
                sqlSession.commit();
            } catch (IOException e) {
                e.printStackTrace();
            }
        }
    }
}
